********************************************************************************
* Lead or follow? Participation decisions in collective development initiatives 

 /* Replication materials
    - Regression tables: this do-file
	- Figures: R-file 
	Contact: bernhard.reinsberg@glasgow.ac.uk
 */
*********************************************************************

* Add packages (if necessary)
*****************************

  ssc install estout, replace
  ssc install reghdfe, replace
  ssc install ftools, replace

  
* Data and variables
********************
	
  use "MBLEAD_replication", clear	
  
  g lngdppc=ln(wdi_gdpcapcon2010)
  g lnoda=ln(oda*1e6)
  g ida_share=moda_ida/moda
  
  egen minyear=min(year), by(childID)
  g ylead2=ylead if year==minyear
  
  g idealsimall=-idealdistall
  g xidealsim=-xidealsimz
    
  replace xsimsectfall=-xsimsectfall
  lab var xsimsectfall "Bilateral salience similarity in TF sector(s)"
  replace xsimsectfz=-xsimsectfz
  lab var xsimsectfz "Bilateral salience similarity in TF sector(s) - TF donors"
  g lntf=ln(1+ntfsecpr)
  lab var lntf "Logged number of pre-existing TFs in any sector"
  g lntfex=ln(1+ntfsecpre)
  lab var lntfex "Logged number of pre-existing TFs in all sector(s)"
  g anybefshare=min(1, follows+leadsbef)
  
  
* Descriptive statistics 
  
  qui estpost su ylead2 yfollow xsecsimall idealsimall xsecsimz xidealsim xsecshare anybefs cabinet lngdppc lnoda ida_share dr_eg vdem_gender g7host xsimsectfall xsimsectfz
  
** Table A4 **  
  esttab ., cells("count mean sd min max") noobs

  foreach x in xsecsimall xsecshare cabinet idealsimall anybefshare{
   egen m_`x'=mean(`x'), by(childID)
   g w_`x'=`x'-m_`x'
   }
  
  foreach x in xsecsimz xsecsimall idealsimall xsecshare anybefshare xidealsim lngdppc lnoda ida_share dr_eg vdem_gender g7host{
   egen M_`x'=mean(`x'), by(iso3)
   g W_`x'=`x'-M_`x'
   }
    
  
* Regressions for leaders
*************************

  qui reghdfe ylead xsecsimall xsecshare cabinet if year==minyear, a(childID) cl(childID)
  est store a11
  qui reghdfe ylead xsecsimall xsecshare cabinet idealsimall anybefshare if year==minyear, a(childID) cl(childID)
  est store a12
  qui reghdfe ylead xsecsimall xsecshare cabinet idealsimall anybefshare lngdppc lnoda ida_share if year==minyear, a(childID) cl(childID)
  est store a13
  qui reghdfe ylead xsecsimall xsecshare cabinet idealsimall anybefshare lngdppc lnoda ida_share dr_eg vdem_gender g7host if year==minyear, a(childID) cl(childID)
  est store a14

** Table 2 **  
  estout a1*, drop(_* ) starlevels(* .1 ** .05 *** .01) cells(b(star fmt(3)) se(par fmt(3))) stats(N N_clust r2, fmt(0 0 3)) 	

  
* Bell-Jones 
  
  qui reg ylead w_xsecsimall m_xsecsimall w_xsecshare m_xsecshare cabinet if year==minyear, cl(childID)
  est store a21
  qui reg ylead w_xsecsimall m_xsecsimall w_xsecshare m_xsecshare cabinet w_idealsimall m_idealsimall w_anybefs m_anybefs xysimtfmean if year==minyear, cl(childID)
  est store a22
  qui reg ylead w_xsecsimall m_xsecsimall w_xsecshare m_xsecshare cabinet w_idealsimall m_idealsimall w_anybefs m_anybefs xysimtfmean lngdppc lnoda ida_share if year==minyear, cl(childID)
  est store a23
  qui reg ylead w_xsecsimall m_xsecsimall w_xsecshare m_xsecshare cabinet w_idealsimall m_idealsimall w_anybefs m_anybefs xysimtfmean lngdppc lnoda ida_share dr_eg vdem_gender g7host if year==minyear, cl(childID)
  est store a24

** Table A5 **  
  estout a2*, drop(_* ) starlevels(* .1 ** .05 *** .01) cells(b(star fmt(3)) se(par fmt(3))) stats(N N_clust r2, fmt(0 0 3)) 	

  
* Competition based on salient sectors 
 
  qui reghdfe ylead xsimsectfall xsecshare cabinet if year==minyear, a(childID) cl(childID)
  est store a31
  qui reghdfe ylead xsimsectfall xsecshare cabinet idealsimall anybefshare if year==minyear, a(childID) cl(childID)
  est store a32
  qui reghdfe ylead xsimsectfall xsecshare cabinet idealsimall anybefshare lngdppc lnoda ida_share if year==minyear, a(childID) cl(childID)
  est store a33
  qui reghdfe ylead xsimsectfall xsecshare cabinet idealsimall anybefshare lngdppc lnoda ida_share dr_eg vdem_gender g7host if year==minyear, a(childID) cl(childID)
  est store a34
  
** Table A6 **  
  estout a3*, drop(_* ) starlevels(* .1 ** .05 *** .01) cells(b(star fmt(3)) se(par fmt(3))) stats(N N_clust r2, fmt(0 0 3)) 	
  
  
* Interaction effects with sector salience and regime density respectively 
 
  qui reghdfe ylead c.xsecsimall##c.xsecshare cabinet if year==minyear, a(childID) cl(childID)
  est store a41
  qui reghdfe ylead c.xsecsimall##c.xsecshare cabinet idealsimall anybefshare if year==minyear, a(childID) cl(childID)
  est store a42
  qui reghdfe ylead c.xsecsimall##c.xysimtfmean cabinet if year==minyear, a(childID) cl(childID)
  est store a43
  qui reghdfe ylead c.xsecsimall##c.xysimtfmean cabinet idealsimall anybefshare if year==minyear, a(childID) cl(childID)
  est store a44

** Table A7 **  
  estout a4*, drop(_* ) starlevels(* .1 ** .05 *** .01) cells(b(star fmt(3)) se(par fmt(3))) stats(N N_clust r2, fmt(0 0 3)) 	
     
  

* Regressions for followers
***************************

  qui reghdfe yfollow xsecsimz xsecshare cabinet, a(childID) cl(child)
  est store b11
  qui reghdfe yfollow xsecsimz xsecshare cabinet xsecsimall idealsimall anybefs xysimtfmean, a(childID) cl(child)
  est store b12
  qui reghdfe yfollow xsecsimz xsecshare cabinet xsecsimall idealsimall anybefs xysimtfmean xidealsim lngdppc lnoda ida_share, a(childID) cl(child)
  est store b13
  qui reghdfe yfollow xsecsimz xsecshare cabinet xsecsimall idealsimall anybefs xysimtfmean xidealsim lngdppc lnoda ida_share dr_eg vdem_gender g7host, a(childID) cl(child)
  est store b14
  
** Table 3 **  
  estout b1*, drop(_* ) starlevels(* .1 ** .05 *** .01) cells(b(star fmt(3)) se(par fmt(3))) stats(N N_clust r2, fmt(0 0 3)) 	
  
  
* Different FE 

  qui reghdfe yfollow xsecsimz xsecshare cabinet, a(childID iso3) cl(child)
  est store b21
  qui reghdfe yfollow xsecsimz xsecshare cabinet xsecsimall idealsimall anybefs xysimtfmean, a(childID iso3) cl(child)
  est store b22
  qui reghdfe yfollow xsecsimz xsecshare cabinet, a(childID iso3code#year) cl(child)
  est store b23
  qui reghdfe yfollow xsecsimz xsecshare cabinet xsecsimall idealsimall anybefs xysimtfmean, a(childID iso3code#year) cl(child)
  est store b24
  
** Table A8 **  
  estout b2*, drop(_* ) starlevels(* .1 ** .05 *** .01) cells(b(star fmt(3)) se(par fmt(3))) stats(N N_clust r2, fmt(0 0 3)) 	
  
  
* Bell-Jones
    
  qui areg yfollow W_xsecsimz M_xsecsimz cabinet, a(childID) cl(childID)
  est store b31
  qui areg yfollow W_xsecsimz M_xsecsimz cabinet W_xsecsimall M_xsecsimall W_idealsimall M_idealsimall W_xsecshare M_xsecshare xysimtfmean, a(childID) cl(childID)
  est store b32
  qui areg yfollow W_xsecsimz M_xsecsimz cabinet W_xsecsimall M_xsecsimall W_idealsimall M_idealsimall W_xsecshare M_xsecshare xysimtfmean W_xidealsim M_xidealsim W_lngdppc M_lngdppc W_lnoda M_lnoda W_ida M_ida, a(childID) cl(childID)
  est store b33
  qui areg yfollow W_xsecsimz M_xsecsimz cabinet W_xsecsimall M_xsecsimall W_idealsimall M_idealsimall W_xsecshare M_xsecshare xysimtfmean W_xidealsim M_xidealsim W_lngdppc M_lngdppc W_lnoda M_lnoda W_ida M_ida W_dr M_dr W_vdem M_vdem W_g7 M_g7, a(childID) cl(childID)
  est store b34
  
** Table A9 **  
  estout b3*, drop(_* ) starlevels(* .1 ** .05 *** .01) cells(b(star fmt(3)) se(par fmt(3))) stats(N N_clust r2, fmt(0 0 3)) 	
  
  
* Competition measure based on salient sectors 
 
  qui reghdfe yfollow xsimsectfz xsecshare cabinet, a(childID) cl(childID)
  est store b41
  qui reghdfe yfollow xsimsectfz xsecshare cabinet xsimsectfall idealsimall anybefshare xysimtfmean, a(childID) cl(childID)
  est store b42
  qui reghdfe yfollow xsimsectfz xsecshare cabinet xsimsectfall idealsimall anybefshare xysimtfmean lngdppc lnoda ida_share, a(childID) cl(childID)
  est store b43
  qui reghdfe yfollow xsimsectfz xsecshare cabinet xsimsectfall idealsimall anybefshare xysimtfmean lngdppc lnoda ida_share dr_eg vdem_gender g7host, a(childID) cl(childID)
  est store b44
  
** Table A10 **  
  estout b4*, drop(_* ) starlevels(* .1 ** .05 *** .01) cells(b(star fmt(3)) se(par fmt(3))) stats(N N_clust r2, fmt(0 0 3)) 	
  
    
* Donor competition conditional on bilateral sector salience and regime density 

  qui reghdfe yfollow c.xsecsimz##c.xsecshare cabinet, a(childID) cl(childID)
  est store b51 
  qui reghdfe yfollow c.xsecsimz##c.xsecshare cabinet idealsimall xsecshare anybefshare xysimtfmean, a(childID) cl(childID)
  est store b52
  qui reghdfe yfollow c.xsecsimz##c.xysimtfmean cabinet , a(childID) cl(childID)
  est store b53 
  qui reghdfe yfollow c.xsecsimz##c.xysimtfmean cabinet idealsimall xsecshare anybefshare, a(childID) cl(childID)
  est store b54

** Table A11 **  
  estout b5*, drop(_* ) starlevels(* .1 ** .05 *** .01) cells(b(star fmt(3)) se(par fmt(3))) stats(N N_clust r2, fmt(0 0 3)) 	

